package cn.lyf.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;
import java.util.List;

//用户发表的博客
@Document("t_blog")
public class Blog {
    @Id
    private String id;
    @Indexed
    private String title;//博客标题
    private String uid;//发表博客的用户id
    private String author;//博客的作者名
    private Integer readnum;  //阅读数
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date  tcreate;//发表时间
    private String msg; //摘要
    private String bodyid;//正文id
    private String blogtypeid;//博客的类型id
    private Integer commentnum;//评论数
    private Integer likenum;//点赞数
    @Field("comments")
    @DBRef
    private List<Comment>  comments;//文章的评论
    private List<String> likeusers;//点赞的用户

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Integer getReadnum() {
        return readnum;
    }

    public void setReadnum(Integer readnum) {
        this.readnum = readnum;
    }

    public Date getTcreate() {
        return tcreate;
    }

    public void setTcreate(Date tcreate) {
        this.tcreate = tcreate;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getBodyid() {
        return bodyid;
    }

    public void setBodyid(String bodyid) {
        this.bodyid = bodyid;
    }

    public String getBlogtypeid() {
        return blogtypeid;
    }

    public void setBlogtypeid(String blogtypeid) {
        this.blogtypeid = blogtypeid;
    }

    public Integer getCommentnum() {
        return commentnum;
    }

    public void setCommentnum(Integer commentnum) {
        this.commentnum = commentnum;
    }

    public List<Comment> getComments() {
        return comments;
    }

    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }

    public Integer getLikenum() {
        return likenum;
    }

    public void setLikenum(Integer likenum) {
        this.likenum = likenum;
    }

    public List<String> getLikeusers() {
        return likeusers;
    }

    public void setLikeusers(List<String> likeusers) {
        this.likeusers = likeusers;
    }

    @Override
    public String toString() {
        return "Blog{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", uid='" + uid + '\'' +
                ", author='" + author + '\'' +
                ", readnum=" + readnum +
                ", tcreate=" + tcreate +
                ", msg='" + msg + '\'' +
                ", bodyid='" + bodyid + '\'' +
                ", blogtypeid='" + blogtypeid + '\'' +
                ", commentnum=" + commentnum +
                ", likenum=" + likenum +
                ", comments=" + comments +
                ", likeusers=" + likeusers +
                '}';
    }
}
